<?php
/**
 * a Cms Page Block wraps an action request
 *
 */
class Cms_Page_Block
{
    public $module;
    public $controller;
    public $action;
    public $params = array();
    public $cachable = true;
    protected $_view;
    /**
     *
     * @param string $action
     * @param string $controller
     * @param string $module
     * @param array $params
     */
    public function __construct ($action = null, $controller = null, $module = null, $params = array())
    {
        $this->action = $action;
        $this->controller = $controller;
        $this->module = $module;
        $this->params = $params;
    }
    /**
     * the render method returns the xhtml response from a MVC request
     *
     * @return XHTML
     */
    public function render ()
    {
        $view = $this->getView();
        return $view->action($this->action, $this->controller, $this->module, $this->params);
    }
    /**
     * Get current view object
     *
     * If no view object currently set, retrieves it from the ViewRenderer.
     * 
     * @todo Set inflector from view renderer at same time
     * @return Zend_View_Interface
     */
    public function getView ()
    {
        if (null === $this->_view) {
            require_once 'Zend/Controller/Action/HelperBroker.php';
            $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
            if (null === $viewRenderer->view) {
                $viewRenderer->initView();
            }
            $this->setView($viewRenderer->view);
        }
        return $this->_view;
    }
    /**
     * Set view object
     * 
     * @param  Zend_View_Interface $view
     * @return Zend_Layout
     */
    public function setView (Zend_View_Interface $view)
    {
        $this->_view = $view;
        return $this;
    }
}
?>